package com.jjx.trainingapi.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jjx.trainingapi.common.RT;
import com.jjx.trainingapi.entity.po.DcNews;
import com.jjx.trainingapi.service.DcNewsCategoryService;
import com.jjx.trainingapi.service.DcNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LoveHuahua
 * @date 2022年05月24日 9:40
 * @description believe in yourself
 */
@RestController
@RequestMapping("/news")
@SaCheckLogin
public class NewsController {

    @Autowired
    private DcNewsService newsService;

    @Autowired
    private DcNewsCategoryService categoryService;


    /**
     * 新闻列表
     *
     * @return
     */
    @PostMapping("/newsList")
    public Object newsList(@RequestBody DcNews news) {
        return RT.ok(newsService.list(Wrappers.lambdaQuery(news)));
    }


    /**
     * 新闻分类列表
     *
     * @return
     */
    @PostMapping("/newsCategoryList")
    public Object newsCategoryList() {
        return RT.ok(categoryService.list());
    }

}
